#include <bits/stdc++.h>
using namespace std;
double d[100005],u[100005],a[100005],p[100005];
int n,m;
double v,l;
int main(){
    freopen("detect3.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,sum;
    cin>>t;
    double cha,su;
    for(int i=1;i<=t;i++){
            sum=0;
        cin>>n>>m>>l>>v;
        for(int j=1;j<=n;j++)cin>>d[j]>>u[j]>>a[j];
        for(int j=1;j<=m;j++)cin>>p[j];
        for(int j=1;j<=n;j++){
            cha=l-d[j];
            su=sqrt(u[j]*u[j]+2*a[j]*cha);
            if(su>v)sum++;
        }
        cout<<sum<<" ";
        if(sum==0)cout<<m<<endl;
        if(sum!=0)cout<<m-1<<endl;
    }

    return 0;
}
